import { Button } from 'antd';
import type { ColumnsType } from 'antd/es/table';

const columns = (onRowNumberClick: (record: any) => void) => {
  const columns: ColumnsType<any> = [
    {
      title: '#',
      dataIndex: 'id',
      key: '__row_number',
      align: 'right',
      width: 48,
      render: (text, record, index) => {
        return (
          <Button
            type="link"
            style={{ padding: 0 }}
            onClick={() => onRowNumberClick(record)}
          >
            <em>{index + 1}</em>
          </Button>
        );
      }
    },
    {
      title: '用户名',
      dataIndex: 'username',
      key: 'username'
    },
    {
      title: '登录时间',
      dataIndex: 'createdAt',
      key: 'createdAt'
    },
    {
      title: 'IP',
      dataIndex: 'ip',
      key: 'ip'
    },
    {
      title: '区域',
      dataIndex: 'region',
      key: 'region'
    },
    {
      title: '操作系统',
      dataIndex: 'os',
      key: 'os'
    },
    {
      title: '浏览器',
      dataIndex: 'browser',
      key: 'browser'
    }
  ];
  return columns;
};

export default columns;
